$(document).ready(function(){

	
	$("#menu-search-box").select2({
		width: 300,
		minimumInputLength: 3,
			ajax: { 
			url: "index.php?module=user&act=ajax&feed_truyen2", 
			dataType: 'json', 
					data: function (term, page){ 
						return {q: term }; 
						}, 
						results: function (data, page) {
							
							return { results: data }; 
							
						}
			}
	});
	
	/*
	 * Load tool tip for anime item
	 */
	$('.load_tooltip').tooltipster({
	    content: 'Loading...',
	    contentAsHTML: true,
	    position: 'right',
	    interactiveTolerance: 100,
	    maxWidth: 530,
	    interactive: false,
	    speed: 150,
	    animation: 'fade',
	    delay: 100,
	    functionBefore: function(origin, continueTooltip) {
	    		
	        // we'll make this function asynchronous and allow the tooltip to go ahead and show the loading notification while fetching our data
	        continueTooltip();
	        
	        // next, we want to check if our data has already been cached
	        if (origin.data('ajax') !== 'cached') {
	            $.ajax({
	                type: 'POST',
	                url: 'loadtooltip.php',
	                success: function(data) {
	                    // update our tooltip content with our returned data and cache it
	                    origin.tooltipster('content', data).data('ajax', 'cached');
	                    
	                    $(".basic").jRating({
	    					bigStarsPath : 'public/images/stars.png', // path of the icon stars.png
	    					smallStarsPath : 'public/images/small.png', // path of the icon small.png
	    					length : 5,
	    					decimalLength : 1,
	    					isDisabled: true,
	    					step: true,
	    					nbRates : 3,
	    					rateMax : 5,
	    					showRateInfo:false,
	    					phpPath : '',
	    				});
	                }
	            });
	        }
	    },
	    
	    functionReady: function(origin, tooltip){
	    	$(".basic").jRating({
				bigStarsPath : 'public/images/stars.png', // path of the icon stars.png
				smallStarsPath : 'public/images/small.png', // path of the icon small.png
				length : 5,
				decimalLength : 1,
				isDisabled: true,
				step: true,
				nbRates : 3,
				rateMax : 5,
				showRateInfo:false,
				phpPath : '',
			});
	    }
	});
	
});

